Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

970
Views
JsPDF Html module producing unusable PDFs [ReactJS]

I'm trying to generate a PDF from a React component. In my scenario it is a MaterialUI table but it could be anything. The problem I'm facing is not with generating the PDF but the produced PDF itself which is too heavy and unusable.

I have a function like this:

createPdf = async (html: HTMLElement, pdfName: string = "report.pdf") => {
    const doc = new jsPDF("p", "pt", "a4", true);

    await doc.html(html, {
      margin: 10,
      html2canvas: {
        scale: 0.65
      },
    });
    doc.save(pdfName);
    return doc.output("blob");
  };

I insert an HTMLElement which is the DOM content for my React component and it generates the PDF correctly. However this pdf is very big and extremely slow to load. Mind that I have an i9 with 32GB of RAM and it easily takes 15secs to render one page of the pdf...

Initially it was generating a 150MB pdf but then I set compressed to true and it's now around 600KB. That changes the size but it didn't improve the performance somehow. I've tried multiple computers and browsers and I've tinkered with the options for html2canvas and nothing seems to fix this.

Does anyone have any insight on this?

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!